package com.example.myworkgwl01;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;


public class friendFragment extends Fragment {
    private friend_adapter adapter;
    private RecyclerView recyclerView;
    private List<String> list = new ArrayList<>();
    private Context context;

    public friendFragment() {
        // Required empty public constructor
    }

    private void initData(){
            for(int i=0;i<30;i++){
                list.add("朋友"+i+"的情况");
            }
    }

    private void initView2(){
        context=this.getActivity();
        adapter=new friend_adapter(context,list);

        LinearLayoutManager manager2=new LinearLayoutManager(context);
        manager2.setOrientation(LinearLayoutManager.VERTICAL);

        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(manager2);
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    }

    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
//        return inflater.inflate(R.layout.friend, container, false);
        View view= inflater.inflate(R.layout.friend, container, false);
        recyclerView=view.findViewById(R.id.item2);
        initData();
        initView2();
        return view;
    }
}